package 设计模式.singleton;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

//JDK1.5出现的 本身是一个class类
public enum EnumSingle {
    INSTANCE;
    public EnumSingle getInstance() {
    return INSTANCE;
    }

    class Test{
        public void main(String[] args) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
            EnumSingle instance1 = EnumSingle.INSTANCE;
            Constructor<EnumSingle> declaredConstructor = EnumSingle.class.getDeclaredConstructor(String.class,int.class);
            declaredConstructor.setAccessible(true);
            EnumSingle instance2 = declaredConstructor.newInstance();
            System.out.println(instance1);
            System.out.println(instance2);

//            EnumSingle instance2 = EnumSingle.INSTANCE;
//
//            System.out.println(instance1);
//            System.out.println(instance2);
        }
    }
}
